﻿#include "OperSpectra.h"
#include "OperatorsInterface/OperAbstractSpectra.h"
#include "GUIFrame/MainWindow.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "GUIWidget/BrowserWidget.h"
#include "GUIFrame/CentralWidget.h"

namespace GUIOper
{

    bool OperSpectra::execGUI()
    {
        GUI::MainWindow * mainWindow = dynamic_cast<GUI::MainWindow *>(FITKAPP->getGlobalData()->getMainWindow());
        if (!mainWindow || !_emitter)return false;
        //获取动作名称
        QString actionName = _emitter->objectName();
        this->createSpectraOper(actionName);
        return true;
    }

    bool OperSpectra::execProfession()
    {
        return false;
    }

    void OperSpectra::createSpectraOper(QString actionName)
    {
        QString name{};
        if (actionName == "actionDampingLossFactor")
        {
            name = "OperatorsSpectraDampingLossFactor";
        }
        else if (actionName == "actionAbsorptionCoefficient")
        {
            name = "OperatorsSpectraAbsorptionCoefficient";
        }
        else if (actionName == "actionModalDensity")
        {
            name = "OperatorsSpectraModalDensity";
        }
        else if (actionName == "actionWavenumber")
        {
            name = "OperatorsSpectraWavenumber";
        }
        else if (actionName == "actionCouplingLossFactor")
        {
            name = "OperatorsSpectraCouplingLossFactor";
        }
        else if (actionName == "actionTransmissionLoss")
        {
            name = "OperatorsSpectraTransmissionLoss";
        }
        else if (actionName == "actionInsertionLoss")
        {
            name = "OperatorsSpectraInsertionLoss";
        }
        else if (actionName == "actionShearModulus")
        {
            name = "OperatorsSpectraShearModulus";
        }
        else
        {
            return;
        }

        auto newOperator = Core::FITKOperatorRepo::getInstance()->getOperatorT<EventOper::OperAbstractSpectra>(name);
        if (newOperator)
            newOperator->createSpectra();
    }
}

